//
//  engine.h
//  RenderV1
//
//  Created by 黄翔 on 2019/9/22.
//  Copyright © 2019 黄翔. All rights reserved.
//

#ifndef engine_h
#define engine_h

#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include "Input.h"
#include "Time.h"
#include "Logger.h"
#include "Video.h"
#include "Scene.h"
#include "HLua.h"
#include "AssetDatabase.h"
#include "ReferenceCounted.h"

namespace hxe
{
class Input;
class Time;
class Logger;
class Video;
class AssetDatabase;
class HLua;

    class Engine: public virtual ReferenceCounted
    {
    public:
        static Engine* createEngine(int width, int height, const char* caption);
        static Engine* getInstance();

    public:
        bool run();
       
        GLFWwindow* getWindow() const;
        Input* getInput() const;
        Time* getTime() const;
        Logger* getLogger() const;
        Video* getVideo() const;
        Scene* getScene() const;
        HLua* getHLua() const;
        AssetDatabase* getAssetDatabase() const;

    private:
        int height;
        int width;
        GLFWwindow* window;
        Input* input;
        Time* time;
        Logger* logger;
        Video* video;
        Scene* scene;
        HLua* hLua;
        AssetDatabase* assetDatabase;
        
    private:
        static Engine* instance;
        static void processMouseInput(GLFWwindow* window, double xPos, double yPos);
        static void frameBufferResize(GLFWwindow* window, int width, int height);
        
    private:
        Engine(int width, int height, const char* caption);
        ~Engine();
    };
}

#endif /* Engine_h */
